package cl.minvu.catastro.manager;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * @author psep
 *
 */
public abstract class AbstractManager {
	
	private EntityManagerFactory emf;
	
	public AbstractManager(){
	}
	
	/**
	 * @return
	 */
	protected EntityManager getEntityManager() {
		emf = Persistence.createEntityManagerFactory("CatastroServices");
		EntityManager em = emf.createEntityManager();
		
		return em;
	}
	
	/**
	 * @param em
	 */
	protected void close(EntityManager em) {
		if (em != null) {
			em.close();
			emf.close();
		}
	}

}
